package BitSet;

import java.util.BitSet;

public class Main {
    public  static void main(String[] args){
        System.out.println("Hello " + "world !");
        BitSet bits1 = new BitSet(16);
        BitSet bits2 = new BitSet(16);

        // set some bits
        for(int i=0; i<16; i++) {
            if((i%2) == 0) bits1.set(i);
            if((i%5) != 0) bits2.set(i);
        }
        System.out.println("Initial pattern in bits1: ");
        System.out.println(bits1);
        System.out.println("\nInitial pattern in bits2: ");
        System.out.println(bits2);
        // AND bits
        bits1.and(bits2);
        System.out.println("\nbits2 AND bits1: ");//与上大家都有的同真即为
        System.out.println(bits1);
        // OR bits
        //有真为真 全假为假
        bits1.or(bits2);
        System.out.println("\nbits2 OR bits1: ");
        System.out.println(bits1);
        // XOR bits
        //异或 异为真 同为否
        System.out.println("\nbits2 XOR bits1: ");
        System.out.println(bits2);
    }
}
